package bobaini.com.strategy_new;

import java.util.HashMap;
import java.util.Map;

/**
 * @author: liuyi
 * ClassName: Test
 * Version: 1.0.0
 * DateTime: 2021/03/31-10:36:00
 * Description: TODO
 */
public class ShareFactoryMain {
    private static final Map<String, ShareStrategy> map = new HashMap<>();

    static {
        map.put("order", new OrderItemShare());
        map.put("single", new SingleItemShare());
        map.put("many", new MultiItemShare());
    }

    private static ShareStrategy getShareStrategy(String param) {
        if (map.containsKey(param)) {
            ShareStrategy shareStrategy = map.get(param);
            return shareStrategy;
        }
        throw new IllegalStateException("当前对象不存在");

    }


    public static void main(String[] args) {
        String str = "many";
        ShareStrategy shareStrategy = getShareStrategy(str);
        shareStrategy.shareAlgorithm(str);
    }
}
